<?php

use Phinx\Migration\AbstractMigration;

class CreateCustomerInvoiceApplyTable extends AbstractMigration
{
    public function up()
    {
        $this->table("customer_invoice_apply", [
            'id' => false,
            'primary_key' => ['id'],
            'engine' => 'InnoDB',
            'collation' => 'utf8mb4_general_ci',
            'comment' => '资格证表'
        ])
            ->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '用户资格证ID'])
            ->addColumn("link_ids", "string", [
                'limit' => 255,
                'null' => false,
                'default' => "",
                'comment' => '关联业务表ids',
            ])
            ->addColumn("link_module_id", "integer", [
                'limit' => 10,
                'signed' => false,
                'null' => false,
                'default' => 0,
                'comment' => "业务表模块id"
            ])
            ->addColumn("status", "enum", [
                'values' => "no,yes",
                'default' => 'no',
                'null' => false,
                'comment' => '开票状态',
            ])
            ->addColumn("invoice_number", "string", [
                'limit' => "255",
                'default' => '',
                'null' => false,
                'comment' => '发票代码',
            ])
            ->addColumn("ship_number", "string", [
                'limit' => "255",
                'default' => '',
                'null' => false,
                'comment' => '快递编号',
            ])
            ->addColumn("invoice_type", "enum", [
                'values' => "paper,electronic",
                'default' => 'paper',
                'null' => false,
                'comment' => '发票类型',
            ])
            ->addColumn("attach_id", "integer", [
                'limit' => 10,
                'signed' => false,
                'null' => false,
                'default' => 0,
                'comment' => "附件id"
            ])
            ->addColumn("money", "decimal", [
                'default' => "0.00",
                'null' => false,
                'signed' => false,
                'precision' => 19,
                'scale' => 2,
                'comment' => "开票金额",
            ])
            ->addColumn('created', 'integer', [
                'signed' => false,
                'default' => 0,
                'limit' => 10,
                'comment' => '创建时间'
            ])
            ->addColumn('updated', 'integer', [
                'signed' => false,
                'default' => 0,
                'limit' => 10,
                'comment' => '更新时间'
            ])
            ->addColumn("tenant_id", "integer", [
                'signed' => false,
                'default' => 0,
                'limit' => 10,
                'comment' => '租户id'
            ])
            ->addColumn('created_by', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建者'])
            ->create();
    }

    public function down()
    {
        $this->table("customer_invoice_apply")->drop()->save();
    }
}
